<template>
  <el-container>
    <el-header :style="{height:this.$store.getters.offsetWidth?95 + 'px':'12vh'}">
      <Header @resizeSideBar="resizeSideBar1"></Header>
    </el-header>
    <el-container style="height:88vh!important;overflow-y: hidden;">
      <Siderbar v-bind:curItemData="curItemData"></Siderbar>
      <el-container style="overflow-y: scroll;">
        <el-main style="padding:0" ref="mainRef" @resize.native="resizeRef">
          <!-- <Breadcrumb></Breadcrumb> -->
          <v-tags @curItem="curItem" :style="{'width':tagsWidth+'px'}"></v-tags>
          <div style="padding:0 20px 20px; margin-top: 40px;">
            <transition name="fade-transform" mode="out-in">
            <router-view></router-view>
          </transition>
          </div>
        </el-main>
        <el-footer>
          <!-- <Footer></Footer> -->
        </el-footer>
      </el-container>
    </el-container>
    <Scrolltotop></Scrolltotop>
  </el-container>
</template>

<script>
import vTags from "../components/Tags.vue";
import Header from "../components/header/Header";
import Breadcrumb from "../components/breadcrumb/Breadcrumb";
import Footer from "../components/footer/Footer";
import Siderbar from "../components/sidebar/Sidebar";
import Scrolltotop from "../components/scrolltotop/Scrolltotop";
import ResizeMixin from "@/utils/resizeHandler";
import bus from "../components/bus";
export default {
  name: "Full",
  components: {
    Header,
    Breadcrumb,
    Footer,
    Siderbar,
    Scrolltotop,
    vTags,
  },
  mixins: [ResizeMixin],
  data() {
    return {
      // users:"Henry",
      isCollapse: false,
      height: "",
      tagsList: [],
      curItemData: "",
      tagsWidth:''
    };
  },

  created() {

    this.height = document.body.clientHeight - 95;
    bus.$on("collapse", (msg) => {
      this.collapse = msg;
    });

    // 只有在标签页列表里的页面才使用keep-alive，即关闭标签之后就不保存到内存中了。
    bus.$on("tags", (msg) => {
      let arr = [];
      for (let i = 0, len = msg.length; i < len; i++) {
        msg[i].name && arr.push(msg[i].name);
      }
      this.tagsList = arr;
    });
  },
  mounted(){
//     this.tagsWidth=this.$refs.mainRef.$el.clientWidth
  window.onresize =()  =>{
         return (()=>{
          this.resizeRef()
         })()
       }
 this.resizeRef()
  },
  methods: {
    resizeSideBar1(e){
      if(e){
        this.tagsWidth=this.tagsWidth+136
      }else{
        this.tagsWidth=this.tagsWidth-136
      }
    },
    resizeRef(){
      this.tagsWidth=this.$refs.mainRef.$el.clientWidth
    },
    toggle() {
      this.isCollapse = !this.isCollapse;
    },
    curItem(val) {
      if (val) {
        this.curItemData = val;
      }
    },
  },
};
</script>

<style scoped lang="stylus">
@media (max-width: 920px) {
  .el-main {
    padding: 0;
  }
}

.el-header {
  color: #333;
  height: 12vh;
  padding: 0;
}
.el-footer{
   height: 0 !important;
}
// .el-header, .el-footer {
//   color: #333;
//   height: 95px !important;
//   padding: 0;
// }
.el-main {
  background-color: #f5f5f5;
  color: #333;
  flex: none;

}

body > .el-container {
  // margin-bottom: 40px;
}

.el-container {
  // height: 100vh;

  overflow-y: hidden;

}

.el-container::-webkit-scrollbar {
  display: none;
}
</style>
